package com.example.broadcastreceiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.TextView;

public class MyAnotherReceiver extends BroadcastReceiver {
    private TextView tvInfo;

    public  MyAnotherReceiver(){}
    public MyAnotherReceiver(TextView tvInfo) {
        this.tvInfo = tvInfo;
    }

    @Override
    public void onReceive(Context context, Intent intent) {
        //日志记录action
        String action = intent.getAction();
        Log.i("info","MyAnotherReceiver接收到广播，action="+action);
        //获取广播消息
        String info = intent.getStringExtra("info");
        Log.i("info","MyAnotherReceiver接收到的广播消息"+info);

        //在文本框显示
        tvInfo.setText(info);


    }
}